function fn () {
    console.log('111');
}

fn.prototype = {
    constructor: fn,
    func1: function () {
        console.log('func1');
    }
};

console.log(fn.prototype);

{
    // 函数的类型
    //-> 单例模式

    let fns1 = {
        func1: function () {
            console.log('1');
        },
        func2: function () {
            console.log('2');
        },
        func3: function () {
            console.log('3');
        }
    };

    let fns2 = {
        func1: function () {
            console.log('a');
        },
        func2: function () {
            console.log('b');
        },
        func3: function () {
            console.log('c');
        }
    };

    fns1.func1();
    fns2.func1();

}

{
    // -> 构造函数

    function Person (name,age,job) {
        this.name = name;
        this.age = age;
        this.job = job;
    }

    Person.prototype = {
        country: 'China',
        show(){
            console.log(this.country);
        }
    };

    let police = new Person('chen',28,'police');
    let doctor = new Person('li',25,'doctor');
    let teacher = new Person('qin',22,'teacher');

    console.log(police.country);
    doctor.show();
    console.log(teacher);
}

{
    // -> 公共属性的检测

    function Fn (name,age) {
        this.name = name;
        this.age= age;
    }

    Fn.prototype = {
        func1: function () {
            console.log('func1 from prototype');
        },
        a: 100
    };

    let fn = new Fn('ws',28);


    console.log("a" in fn);
    console.log(fn.a);
    console.log(fn.hasOwnProperty('name'));
    console.log(fn.hasOwnProperty('a'));


}

{
    // constuctor

    function Fn (name,age) {
        this.name = name;
        this.age = age;
    }

    Fn.prototype = {
        fn1: function () {
            console.log(this.name);
        },
        fn2: function () {
            console.log(this.age);
        }
    };

    console.log(Fn.prototype.constructor);
}